<?php /*a:2:{s:40:"D:\www\long_shop\app\view\cat\index.html";i:1726918766;s:42:"D:\www\long_shop\app\view\common\head.html";i:1702389678;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/jquery/jquery-1.12.4.min.js"></script>    
    <link href="/static/bst5.3.2/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/bst5.3.2/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="/static/bst-icons/font/bootstrap-icons.css">
    <script src="/static/layer/layer/layer.js"></script>
    <link rel="stylesheet" href="/static/css/my.css">    
</head>
<head>
    <title>商品分类管理</title>
    <style>
    </style>
</head>
<body >
<div class="container-fluid">
    <div class="row">
        <div class="col-2" style="text-align: left;line-height: 50px;font-size: 2rem;" >
            商品分类管理
        </div>
        <div class="col-10">    
        </div>
    </div>    
    <table class="table table-sm table-hover table-striped">
        <thead>
            <th>序号</th>
            <th>分类名称</th>
            <th>说明</th>
            <th>排序</th>
            <th>录入人</th>
            <th>录入时间</th>
            <th>是否启用</th>
            <th>
                <a href="/index.php/cat/cat_add" alt="新增分类(New category)">
                <button type="button" class="btn btn-sm btn-primary">
                        <span class="bi-plus-lg" style="color:#fff;"></span>
                </button></a>

            </th>
        </thead>
        <tbody>
            <?php foreach($data as $k=>$kv): ?>
            <tr>
                <td><?php echo htmlentities($k); ?></td>
                <td <?php if($kv['status']!=1): ?> style="color:red;" <?php endif; ?>>
                    <?php if($kv['deepth']==1): ?>
                        <c style="margin-left:10px;"></c>|__
                    <?php elseif($kv['deepth']==2): ?>
                        <c style="margin-left:20px;"></c>|__
                    <?php elseif($kv['deepth']==3): ?>
                        <c style="margin-left:40px;"></c>|__
                    <?php endif; ?>
                    <?php echo htmlentities($kv['name']); ?>
                    
                </td>
                <td><?php echo htmlentities($kv['title']); ?></td>
                <td><?php echo htmlentities($kv['sort']); ?> </td>
                <td><?php echo htmlentities($kv['creater_name']); ?></td>
                <td><?php echo htmlentities($kv['create_time']); ?></td>
                <?php if($kv['status']==1): ?>
                    <td><?php echo htmlentities($kv['status_name']); ?></td>
                <?php else: ?>    
                    <td style="text-decoration:line-through;color:red;"><?php echo htmlentities($kv['status_name']); ?></td>
                <?php endif; ?>
                <td>
                    <a href="/index.php/cat/edit/id/<?php echo htmlentities($kv['id']); ?>">
                        <button type="button" class="btn btn-sm btn-info"><span class="bi-pencil" ></span></button>
                    </a> 

                    <?php if($kv['status']==2): ?>
                    <button type="button" class="btn btn-sm btn-dark cat_del" cat_id="<?php echo htmlentities($kv['id']); ?>">
                        <span class="bi-x" ></span>
                    </button>

                    <?php endif; ?>
                </td>
            </tr>
            <?php endforeach; ?>

        </tbody>    
    </table>
</div>

</body>

<script type="text/javascript">
  $(function(){
    $('.cat_del').on('click',function(){
        var cat_id=$(this).attr('cat_id');
            //询问框

        layer.confirm('是否确定删除项目?', {
          btn: ['确定删除','再检查一下'] //按钮
        }, function(){

            $.ajax({
                url:'/index.php/cat/del',
                type:'post',
                data:{id:cat_id},
                success:function(res){
                    if(res.code){
                        layer.msg('删除成功!');
                        location.reload();
                    }else{
                        layer.msg(res.msg);
                    }
                     
                },
                fail:function(res){
                    layer.msg(res.code+'failed!');
                }
            });

            e.preventDefault(); 
            
        }, function(){
            layer.msg('操作取消！');
            return false;
            e.preventDefault(); //阻止冒泡
        }); 


    })
  })

</script>


</body>
</html>
